package com.qlujavateam.service;

import com.qlujavateam.sqloperation.ToQDRecord;
import com.qlujavateam.sqloperation.ToStudent;
import com.qlujavateam.methods.Student;

public class StudentService {
	private ToStudent sdao = new ToStudent();
	private ToQDRecord qddao=new ToQDRecord();

	public Student studentLogin(String sphone, String spass) {

		Student s = sdao.queryBySphone2(sphone);
		if (s == null) {
			throw new RuntimeException("查无此人");
		}

		if (!s.getSpassword().equals(spass)) {
			throw new RuntimeException("用户名或密码错误");
		}

		return s;
	}

	/*
	 * 得到班级的总人数和已经签到的学生数量
	 */
	public int[] getStuCountAndQDCount(String classno,String day,String time) {
		//某个班的总人数
		int totleCount = sdao.queryStudentCountByClassNo(classno);
		//某个班 某一天 某个上课时间段 已有的敲到数据
		int qdcount=qddao.queryQDCount(Integer.parseInt(classno), day, time);
		
		int[] results={totleCount,qdcount};
		
		return results;
		
	}

}
